/*******************************************************************
 * Copyright (c) 2013 珠海比特讯科技有限公司. All rights reserved.
 * （1）软件的版权将受到法律保护，不允许非经授权的使用；
 * （2）未经版权所有人授权，任何人不得修改、复制和传播软件源代码、图片及其它资源等；
 * （3）未经版权所有人授权，不允许对软件进行修改；
 * （4）未经版权所有人授权，不允许在该软件的基础上开发新的软件；
 * （5）珠海比特讯科技有限公司拥有最终解释权
 *******************************************************************/
package youxiao.bytezon.models;

import java.math.BigDecimal;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

@Entity
@Table(name = "course")
public class Course {

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	private long id;

	@Column(nullable = false)
	private String shortName;

	@Column
	private String extName;

	@Column
	private BigDecimal price;

	@Column(nullable = false)
	private int applylearnCount;

	@Column(nullable = false)
	private int trialCount;

	@Column(nullable = false)
	private int lessonCount;

	@Column(nullable = false)
	private int finishLessonCount;

	@Column
	private String courseTime;

	@Column
	private String remark;

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "coursetype_id")
	private Coursetype coursetype;

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "school_id")
	protected School school;
	
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "teacher_id")
	protected Teacher teacher;

	@OneToMany(mappedBy = "course", orphanRemoval = true)
	private Set<CourseDetail> courseDetails = new HashSet<CourseDetail>(0);

	@OneToMany(mappedBy = "course", orphanRemoval = true)
	private Set<StudentCourse> studentCourses = new HashSet<StudentCourse>(0);

	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public String getShortName() {
		return shortName;
	}

	public void setShortName(String shortName) {
		this.shortName = shortName;
	}

	public School getSchool() {
		return school;
	}

	public void setSchool(School school) {
		this.school = school;
	}

	public Coursetype getCoursetype() {
		return coursetype;
	}

	public void setCoursetype(Coursetype coursetype) {
		this.coursetype = coursetype;
	}

	public String getExtName() {
		return extName;
	}

	public void setExtName(String extName) {
		this.extName = extName;
	}

	public int getApplylearnCount() {
		return applylearnCount;
	}

	public void setApplylearnCount(int applylearnCount) {
		this.applylearnCount = applylearnCount;
	}

	public int getTrialCount() {
		return trialCount;
	}

	public void setTrialCount(int trialCount) {
		this.trialCount = trialCount;
	}

	public int getLessonCount() {
		return lessonCount;
	}

	public void setLessonCount(int lessonCount) {
		this.lessonCount = lessonCount;
	}

	public int getFinishLessonCount() {
		return finishLessonCount;
	}

	public void setFinishLessonCount(int finishLessonCount) {
		this.finishLessonCount = finishLessonCount;
	}

	public String getCourseTime() {
		return courseTime;
	}

	public void setCourseTime(String courseTime) {
		this.courseTime = courseTime;
	}

	public BigDecimal getPrice() {
		return price;
	}

	public void setPrice(BigDecimal price) {
		this.price = price;
	}

	public Set<CourseDetail> getCourseDetails() {
		return courseDetails;
	}

	public void setCourseDetails(Set<CourseDetail> courseDetails) {
		this.courseDetails = courseDetails;
	}

	public Set<StudentCourse> getStudentCourses() {
		return studentCourses;
	}

	public void setStudentCourses(Set<StudentCourse> studentCourses) {
		this.studentCourses = studentCourses;
	}

	public String getFullName() {
		return this.shortName + this.extName;
	}

	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	public Teacher getTeacher() {
		return teacher;
	}

	public void setTeacher(Teacher teacher) {
		this.teacher = teacher;
	}

}
